package com.hrhx.duhongming.core;

import java.util.List;
import java.util.Map;

import com.github.abel533.echarts.json.GsonOption;
import com.hrhx.duhongming.adapter.echarts.EchartsDoubleNumLineAdapter;
import com.hrhx.duhongming.adapter.echarts.EchartsLineAndBarAdapter;
import com.hrhx.duhongming.adapter.echarts.EchartsMapAdapter;
import com.hrhx.duhongming.adapter.echarts.EchartsPieAdapter;
import com.hrhx.duhongming.adapter.echarts.EchartsRadarAdapter;
import com.hrhx.duhongming.adapter.echarts.EchartsReverseBarAdapter;
import com.hrhx.duhongming.adapter.echarts.EchartsScatterAdapter;
import com.hrhx.duhongming.bean.EchartsConfig;

public class EchartsCore extends EchartsBaseCore{
	
	public EchartsCore(){
		super();
	}
	
	public static EchartsCore getInstance(){
        return new EchartsCore();
    }		
	public GsonOption getBaseGsonOption(EchartsConfig echartsConfig){
		//1.获取option对象
		GsonOption gsonOption = getBaseTitle(echartsConfig);
		//2.提示信息
		getBaseTooltip(echartsConfig);
		//3.工具栏处理
		getBarAndLineToolBox(echartsConfig);
		//4.数据域缩放处理
		getDataZoom(echartsConfig);
		//5.视觉映射组件
		getVisualMap(echartsConfig);
		return gsonOption;
	}
	
	/**
	 * 柱状图和折线图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return GsonOption
	 */
	public GsonOption adapterLineAndBar(EchartsConfig echartsConfig,GsonOption gsonOption,List<Map<String,Object>> data){		
		return EchartsLineAndBarAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
	/**
	 * 饼状图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return GsonOption
	 */
	public GsonOption adapterPie(EchartsConfig echartsConfig,GsonOption gsonOption,Map<String,Object> data){		
		return EchartsPieAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
	/**
	 * 散点图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return GsonOption
	 */
	public GsonOption adapterScatter(EchartsConfig echartsConfig,GsonOption gsonOption,Object[][] data){		
		return EchartsScatterAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
	/**
	 * 双数值折线图适配器<p>
	 * 时间数值折线图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return
	 */
	public GsonOption adapterDoubleNumLine(EchartsConfig echartsConfig,GsonOption gsonOption,Map<String,Object[][]> data){		
		return EchartsDoubleNumLineAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
	/**
	 * 反转柱状图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return GsonOption
	 */
	public GsonOption adapterReverseBar(EchartsConfig echartsConfig,GsonOption gsonOption,List<Map<String,Object>> data){		
		return EchartsReverseBarAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
	/**
	 * 雷达图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return GsonOption
	 */
	public GsonOption adapterRadar(EchartsConfig echartsConfig,GsonOption gsonOption,List<Map<String,Object>> data){		
		return EchartsRadarAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
	/**
	 * 地图适配器
	 * @param echartsConfig
	 * @param gsonOption
	 * @param data
	 * @return GsonOption
	 */
	public GsonOption adapterMap(EchartsConfig echartsConfig, GsonOption gsonOption,Map<String, Map<String, Double>> data) {
		return EchartsMapAdapter.me.adapter(echartsConfig,gsonOption,data);
	}
	
}
